package com.nj.api.web.advice;

import com.nj.api.exception.MsgTipException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

@RestControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler(MsgTipException.class)
    public Map msgTipException(Exception e) {
        e.printStackTrace();
        return new HashMap(){{
            put("success",false);
            put("errMsg",e.getMessage());
        }};
    }

    @ExceptionHandler(Exception.class)
    public Map exception(Exception e) {
        e.printStackTrace();
        return new HashMap(){{
            put("success",false);
            put("errMsg","系统忙，请稍后再试试");
        }};
    }
}
